﻿@{
    ViewData["Title"] = "Index";
    Layout = null;
}



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>电脑网站2.0支付</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul, ol {
            list-style: none;
        }

        body {
            font-family: "Helvetica Neue",Helvetica,Arial,"Lucida Grande",sans-serif;
        }

        .tab-head {
            margin-left: 120px;
            margin-bottom: 10px;
        }

        .tab-content {
            clear: left;
            display: none;
        }

        h2 {
            border-bottom: solid #02aaf1 2px;
            width: 200px;
            height: 25px;
            margin: 0;
            float: left;
            text-align: center;
            font-size: 16px;
        }

        .selected {
            color: #FFFFFF;
            background-color: #02aaf1;
        }

        .show {
            clear: left;
            display: block;
        }

        .hidden {
            display: none;
        }

        .new-btn-login-sp {
            padding: 1px;
            display: inline-block;
            width: 75%;
        }

        .new-btn-login {
            background-color: #02aaf1;
            color: #FFFFFF;
            font-weight: bold;
            border: none;
            width: 100%;
            height: 30px;
            border-radius: 5px;
            font-size: 16px;
        }

        #main {
            width: 100%;
            margin: 0 auto;
            font-size: 14px;
        }

        .red-star {
            color: #f00;
            width: 10px;
            display: inline-block;
        }

        .null-star {
            color: #fff;
        }

        .content {
            margin-top: 5px;
        }

            .content dt {
                width: 100px;
                display: inline-block;
                float: left;
                margin-left: 20px;
                color: #666;
                font-size: 13px;
                margin-top: 8px;
            }

            .content dd {
                margin-left: 120px;
                margin-bottom: 5px;
            }

                .content dd input {
                    width: 85%;
                    height: 28px;
                    border: 0;
                    -webkit-border-radius: 0;
                    -webkit-appearance: none;
                }

        #foot {
            margin-top: 10px;
            position: absolute;
            bottom: 15px;
            width: 100%;
        }

        .foot-ul {
            width: 100%;
        }

            .foot-ul li {
                width: 100%;
                text-align: center;
                color: #666;
            }

        .note-help {
            color: #999999;
            font-size: 12px;
            line-height: 130%;
            margin-top: 5px;
            width: 100%;
            display: block;
        }

        #btn-dd {
            margin: 20px;
            text-align: center;
        }

        .foot-ul {
            width: 100%;
        }

        .one_line {
            display: block;
            height: 1px;
            border: 0;
            border-top: 1px solid #eeeeee;
            width: 100%;
            margin-left: 20px;
        }

        .am-header {
            display: -webkit-box;
            display: -ms-flexbox;
            display: box;
            width: 100%;
            position: relative;
            padding: 7px 0;
            -webkit-box-sizing: border-box;
            -ms-box-sizing: border-box;
            box-sizing: border-box;
            background: #1D222D;
            height: 50px;
            text-align: center;
            -webkit-box-pack: center;
            -ms-flex-pack: center;
            box-pack: center;
            -webkit-box-align: center;
            -ms-flex-align: center;
            box-align: center;
        }

            .am-header h1 {
                -webkit-box-flex: 1;
                -ms-flex: 1;
                box-flex: 1;
                line-height: 18px;
                text-align: center;
                font-size: 18px;
                font-weight: 300;
                color: #fff;
            }

        html, body {
            margin: 0;
            height: 100%;
        }

        #divshelter {
            width: 100%;
            height: 100%;
            background-color: #000;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2;
            opacity: 0.3;
            /*兼容IE8及以下版本浏览器*/
            filter: alpha(opacity=30);
            display: none;
        }

        #divtip {
            width: 300px;
            height: 160px;
            background-color: #E7EAED;
            margin: auto;
            position: absolute;
            z-index: 3;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            display: none;
        }
    </style>

    <script src="~/libs/jquery/jquery.js"></script>
</head>

<body>
    <form id="form1" runat="server">
        <div>
            <div id="body1" class="show" name="divcontent">
                <dl class="content">
                    <dt>
                        商户订单号
                        ：
                    </dt>
                    <dd>
                        <input id="WIDout_trade_no" name="WIDout_trade_no" />
                    </dd>
                    <hr class="one_line">
                    <dt>
                        订单名称
                        ：
                    </dt>
                    <dd>
                        <input id="WIDsubject" name="WIDsubject" />
                    </dd>
                    <hr class="one_line">
                    <dt>
                        付款金额
                        ：
                    </dt>
                    <dd>
                        <input id="WIDtotal_amount" name="WIDtotal_amount" />
                    </dd>
                    <hr class="one_line">
                    <dt>商品描述：</dt>
                    <dd>
                        <input id="WIDbody" name="WIDbody" />
                    </dd>
                    <hr class="one_line">
                    <dt>
                        创建时间
                        ：
                    </dt>
                    <dd>
                        <input id="createTime" name="createTime" />
                    </dd>
                    <hr class="one_line">
                    <dt>
                        申请人
                        ：
                    </dt>
                    <dd>
                        <input id="name" name="name" value="@ViewBag.Name"/>
                    </dd>
                    <hr class="one_line">
                    <dt></dt>
                    <dd id="btn-dd">
                        <span class="new-btn-login-sp">
                            <input type="button" id="BtnAlipay" name="BtnAlipay" class="new-btn-login" value="确 认" Style="text-align: center;" onclick="alipaysubmit()" />
                        </span>
                        <span class="note-help">如果您点击“付款”按钮，即表示您同意该次的执行操作。</span>
                    </dd>
                </dl>
            </div>
        </div>
    </form>
    <div id="divshelter"></div>
    <div id="divtip">
        <a style="float:right; padding-right:10px;" href="javascript:cancellog()">关闭</a>
        <div style="padding:55px 0 0 35px;">订单支付中，请勿关闭页面....</div>
    </div>

    <script language="javascript">

            function GetDateNow() {
                var vNow = new Date();
                var sNow = "";
                sNow += String(vNow.getFullYear());
                sNow += String(vNow.getMonth() + 1);
                sNow += String(vNow.getDate());
                sNow += String(vNow.getHours());
                sNow += String(vNow.getMinutes());
                sNow += String(vNow.getSeconds());
                sNow += String(vNow.getMilliseconds());
                $("#WIDout_trade_no").val(sNow);
                $.ajax({
                    url:"/Payment/GetById?id="+@ViewBag.Id,
                    type:"get",
                    dataType:"json",
                    success:function(obj){
                        console.log(obj)
                        $("#WIDsubject").val(obj.title);
                        $("#WIDtotal_amount").val(obj.paymentPrice);
                        $("#WIDbody").val(obj.purposePescription);
                        $("#createTime").val(obj.createTime);
                        $("#createTime").val(renderTime(obj.createTime));
                    }
                })
            }
            GetDateNow();

             function renderTime(date) {
                var dateee = new Date(date).toJSON();
                return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
            }

            function openshelter() {
                var s = document.getElementById("divshelter");
                s.style.display = "block";

                var l = document.getElementById("divtip");
                l.style.display = "block";
            }

            function cancellog() {
                var s = document.getElementById("divshelter");
                s.style.display = "none";

                var l = document.getElementById("divtip");
                l.style.display = "none";
            }

            function alipaysubmit() {
                var tradeNo = $("#WIDout_trade_no").val();
                var subject = $("#WIDsubject").val();
                var totalAmount = $("#WIDtotal_amount").val();
                var body = $("#WIDbody").val();

                $.ajax({
                    type: "post",
                    url: "/Pay/AlipaySubmit",
                    data: { tradeNo: tradeNo, subject: subject, totalAmount: totalAmount, body: body },
                    success: function (obj) {
                        console.log(obj);
                        if (obj.result) {
                            window.open().document.write(obj.formData);
                        } else {
                            alert(obj.formData);
                        }
                    }
                })

                openshelter();
                setInterval("goback()", 4000);
            }

            function goback() {
                var tradeNo = $("#WIDout_trade_no").val();
                var totaAamount = $("#WIDtotal_amount").val();
                $.ajax({
                    type: "post",
                    url: "/Pay/CheckPaymen",
                    data: { tradeNo: tradeNo, totaAamount: totaAamount },
                    success: function (obj) {
                        console.log(obj);
                        if (obj.status != '0') {
                            cancellog();
                            window.location.href = '/Payment/PayIndex';
                        }
                    }
                })
            }

    </script>
</body>
</html>
